package com.example.article;

import org.jasypt.encryption.pbe.StandardPBEStringEncryptor;
import org.jasypt.encryption.pbe.config.EnvironmentStringPBEConfig;

public class Test {
    public static void main(String[] args) {
        System.out.println(encrypt("@Xiaozhuang","abc"));
    }

//    数据库密码加密
    public static String encrypt(String password, String factor) {
        //加密工具
        StandardPBEStringEncryptor encryptor = new StandardPBEStringEncryptor();
        //加密配置
        EnvironmentStringPBEConfig config = new EnvironmentStringPBEConfig();
        config.setAlgorithm("PBEWithMD5AndDES");
        //秘钥
        config.setPassword(factor);
        //应用配置
        encryptor.setConfig(config);
        //加密
        return encryptor.encrypt(password);
    }
}
